
package com.jf.cloud.delivery.feign;


import com.jf.cloud.api.delivery.feign.AreaFeignClient;
import com.jf.cloud.api.delivery.vo.AreaVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.delivery.service.AreaService;
import io.swagger.v3.oas.annotations.Operation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;

import java.util.List;


/**
 * @author zz
 * @date 2021/06/02
 */
@RestController
@Hidden
public class AreaFeignController implements AreaFeignClient {

    @Autowired
    private AreaService areaService;

    @Autowired
    private MapperFacade mapperFacade;

    @Override
    public ServerResponseEntity<List<AreaVO>> listProvinceArea() {
        return ServerResponseEntity.success(mapperFacade.mapAsList(areaService.getAreaListInfo(), AreaVO.class));
    }

    @Override
    public ServerResponseEntity<AreaVO> getArea(Long areaId) {
        return ServerResponseEntity.success(areaService.getByAreaId(areaId));
    }

    @Override
    public ServerResponseEntity<AreaVO> getAreaByName(String areaName) {
        return ServerResponseEntity.success(areaService.getByAreaName(areaName));
    }

    @Override
    public ServerResponseEntity<List<AreaVO>> listByPid(Long pid) {
        List<AreaVO> list = areaService.listByPid(pid);
        return ServerResponseEntity.success(list);
    }
}
